package com.yn.sample;

import com.yn.sample.domain.ClassInfo;
import com.yn.sample.execution.MethodExecutionEngine;
import com.yn.sample.parser.JavapClassFileParser;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

@Component
@ComponentScan("com.yn.sample")
public class BootStrap {
    public static void main(String[] args) throws Throwable {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BootStrap.class);
        /**
         * 解析文件
         */
//        String filepath = "F:\\gitee-ckl\\all-simple-demo-in-work\\class-bytecode-analyse-engine\\target\\classes\\com\\yn\\sample\\a.txt";
        String filepath = "F:\\ownprojects\\all-simple-demo-in-work\\class-bytecode-analyse-engine\\target\\classes\\com\\yn\\sample\\a.txt";
        JavapClassFileParser javapClassFileParser = context.getBean(JavapClassFileParser.class);
        ClassInfo classInfo = javapClassFileParser.parse(filepath);

        CheckAndSet target = new CheckAndSet();
        MethodExecutionEngine executionEngine = context.getBean(MethodExecutionEngine.class);
//
//        {
//            /**
//             * 传递一个变量，2
//             */
//            ArrayList<Object> arguments = new ArrayList<>();
//            arguments.add(12);
//            Object o = executionEngine.execute(target, "checkAndSetF1(int)", classInfo, arguments);
//            System.out.println("result:" + o);
//        }



        {
            /**
             * 传递一个变量，2
             */
            ArrayList<Object> arguments = new ArrayList<>();
            arguments.add(12);
            Object o = executionEngine.execute(target, "checkAndSetF(int)", classInfo, arguments);
            System.out.println("result:" + o);
        }


    }
}
